//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "FranceRegion.h"
using namespace Cephei::QL::Indexes;
#include <gen/QL/Indexes/Region.h>
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Indexes::CFranceRegion::CFranceRegion () : CRegion(CFranceRegion::typeid)
{
    try
    {
#ifdef HANDLE
        _phFranceRegion = NULL;
#endif
        _ppFranceRegion = new boost::shared_ptr<QuantLib::FranceRegion> (new QuantLib::FranceRegion ( ));
        SetRegion (boost::dynamic_pointer_cast<QuantLib::Region> (*_ppFranceRegion));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Indexes::CFranceRegion::CFranceRegion (boost::shared_ptr<QuantLib::FranceRegion>& childNative, Object^ owner) : CRegion(CFranceRegion::typeid)
{
#ifdef HANDLE
	_phFranceRegion = NULL;
#endif
	_ppFranceRegion = &childNative;
    _ppRegion = new boost::shared_ptr<QuantLib::Region> (boost::dynamic_pointer_cast<QuantLib::Region> (*_ppFranceRegion));
}
Cephei::QL::Indexes::CFranceRegion::CFranceRegion (QuantLib::FranceRegion& childNative, Object^ owner) : CRegion(CFranceRegion::typeid)
{
#ifdef HANDLE
	_phFranceRegion = NULL;
#endif
	_ppFranceRegion = new boost::shared_ptr<QuantLib::FranceRegion> (&childNative);
    _ppRegion = new boost::shared_ptr<QuantLib::Region> (boost::dynamic_pointer_cast<QuantLib::Region> (*_ppFranceRegion));
    _FranceRegionOwner = owner;
    _RegionOwner = owner;
}

Cephei::QL::Indexes::CFranceRegion::CFranceRegion (CFranceRegion^ copy) : CRegion(CFranceRegion::typeid)
{
#ifdef HANDLE
	_phFranceRegion = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppFranceRegion = new boost::shared_ptr<QuantLib::FranceRegion> (copy->GetShared());
        _ppRegion = new boost::shared_ptr<QuantLib::Region> (boost::dynamic_pointer_cast<QuantLib::Region> (*_ppFranceRegion));
    }
}
Cephei::QL::Indexes::CFranceRegion::CFranceRegion (PLATFORM::Type^ t) : CRegion(CFranceRegion::typeid)
{
#ifdef HANDLE
	_phFranceRegion = NULL;
#endif
	if (!t->IsSubclassOf(CFranceRegion::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Indexes::CFranceRegion::CFranceRegion (QuantLib::Handle<QuantLib::FranceRegion>& childNative, Object^ owner)  : CRegion(CFranceRegion::typeid)
{
	_phFranceRegion = &childNative;
	_ppFranceRegion = &static_cast<boost::shared_ptr<QuantLib::FranceRegion>>(childNative.currentLink());
    _ppRegion = new boost::shared_ptr<QuantLib::Region> (boost::dynamic_pointer_cast<QuantLib::Region> (*_ppFranceRegion));
    _FranceRegionOwner = owner;
}
Cephei::QL::Indexes::CFranceRegion::CFranceRegion (QuantLib::Handle<QuantLib::FranceRegion> childNative)  : CRegion(CFranceRegion::typeid)
{
	_phFranceRegion = &childNative;
	_ppFranceRegion = &static_cast<boost::shared_ptr<QuantLib::FranceRegion>>(childNative.currentLink());
    _ppRegion = new boost::shared_ptr<QuantLib::Region> (boost::dynamic_pointer_cast<QuantLib::Region> (*_ppFranceRegion));
}
#endif
#ifdef STRUCT
Cephei::QL::Indexes::CFranceRegion::CFranceRegion (QuantLib::FranceRegion childNative)  : CRegion(CFranceRegion::typeid)
{
#ifdef HANDLE
	_phFranceRegion = NULL;
#endif
	_ppFranceRegion = new boost::shared_ptr<QuantLib::FranceRegion> (new QuantLib::FranceRegion (childNative));
    _ppRegion = new boost::shared_ptr<QuantLib::Region> (boost::dynamic_pointer_cast<QuantLib::Region> (*_ppFranceRegion));
}
#endif

Cephei::QL::Indexes::CFranceRegion::~CFranceRegion ()
{
    if (_ppFranceRegion != NULL)
    {
	    delete _ppFranceRegion;
        _ppFranceRegion = NULL;
    }
}
Cephei::QL::Indexes::CFranceRegion::!CFranceRegion ()
{
    if (_ppFranceRegion != NULL)
    {
	    delete _ppFranceRegion;
    }
}
QuantLib::FranceRegion& Cephei::QL::Indexes::CFranceRegion::GetReference ()
{
    if (_ppFranceRegion == NULL) throw REFNEW NativeNullException ();
	return **_ppFranceRegion;
}
boost::shared_ptr<QuantLib::FranceRegion>& Cephei::QL::Indexes::CFranceRegion::GetShared ()
{
    if (_ppFranceRegion == NULL) throw REFNEW NativeNullException ();
	return *_ppFranceRegion;
}
QuantLib::FranceRegion* Cephei::QL::Indexes::CFranceRegion::GetPointer ()
{
    if (_ppFranceRegion == NULL) throw REFNEW NativeNullException ();
	return &**_ppFranceRegion;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::FranceRegion>& Cephei::QL::Indexes::CFranceRegion::GetHandle ()
{
	if (_phFranceRegion == NULL)
	{
		_phFranceRegion = new Handle<QuantLib::FranceRegion> (*_ppFranceRegion);
	}
	return *_phFranceRegion;
}
#endif
bool Cephei::QL::Indexes::CFranceRegion::HasNative () 
{
	return (_ppFranceRegion != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Indexes::IFranceRegion^ Cephei::QL::Indexes::CFranceRegion_Factory::Create ()
{
    return REFNEW CFranceRegion ();
}
